﻿#define _CRT_SECURE_NO_WARNINGS 1

//编程初学者入门训练第107题
//BC109 杨辉三角
//https://www.nowcoder.com/practice/e671c6a913d448318a49be87850adbcc?tpId=107&tqId=33390&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D3%26tpId%3D107%26type%3D107&difficulty=undefined&judgeStatus=undefined&tags=&title=

#include <stdio.h>

int main() {
    int n = 0;
    scanf("%d", &n);
    int arr[30][30];
    //生成杨辉三角
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j || j == 0)
                arr[i][j] = 1;
            else
                arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j];
        }
    }
    //打印
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            printf("%5d", arr[i][j]);
        }
        printf("\n");
    }

    return 0;
}